package com.ccsc.auth.utils;

import java.util.UUID;

/**
 * Created by XingWen on 2017/2/10.
 */
public class UUIDUtil {
    public UUIDUtil() {
    }

    public static String genUUIDWithSepChr() {
        UUID uuid = UUID.randomUUID();
        String str = uuid.toString();
        return str;
    }

    public static String genUUID() {
        String str = genUUIDWithSepChr();
        // 去掉"-"
        String temp = str.substring(0, 8) + str.substring(9, 13) + str.substring(14, 18) + str.substring(19, 23) + str.substring(24);
        return temp;
    }

    //获得指定数量的UUID
    private static String[] genUUID(int number) {
        if (number < 1) {
            return null;
        }
        String[] ss = new String[number];
        for (int i = 0; i < number; i++) {
            ss[i] = genUUID();
        }
        return ss;
    }

    public static void main(String[] args) {
        System.out.println(genUUID());
    }
}
